/**
 * Perform login validations
 */
function validtation()
{
	var vehreg = document.forms["vehicleForm"]["vehicleRegistrationNo"].value;
	var model = document.forms["vehicleForm"]["model"].value;
	var policyType = document.forms["vehicleForm"]["policyType"].value;
	
	if(model == "")
	{
		
		document.getElementById('modelType').innerHTML='Select vehicle model';

		}
	
	else{
		document.getElementById('modelType').innerHTML='';
		}
	if(vehreg=="")
	{
		document.getElementById('registration').innerHTML='Registration No should not be empty';
		return false;
		}

	 // allow only letters, numbers, and underscores
    var i = /[\W_]/;
    if(i.test(vehreg))
    {
	   
    	document.getElementById('registration').innerHTML = 'Registration No contains illegal characters';
        return false;
	    } 
	
	if(vehreg.length!=6)
	{
		document.getElementById('registration').innerHTML='Registration No should be of 6 characters';
		return false;
		}
	else
	{
		document.getElementById('registration').innerHTML='';
		
		}
		
	if(policyType.length==1)
	{
		
		document.getElementById('tpolicy').innerHTML='Select Policy Type';
		return false;

		}
	
	
	return true;
}

function setOptions(chosen) {
	var policyAmount = document.vehicleForm.policyAmount;
	 
	policyAmount.options.length = 0;
	if (chosen == " ") {
	  policyAmount.options[policyAmount.options.length] = new Option('-select-');
	 
	}
	if (chosen == "Bodily Injury") {
	  policyAmount.options[policyAmount.options.length] = new
	Option('$5000','5000');
	  policyAmount.options[policyAmount.options.length] = new
	Option('$10,000','10000');
	  policyAmount.options[policyAmount.options.length] = new
		Option('$15,000','15000');
	}
	if (chosen == "Collision") {
	  policyAmount.options[policyAmount.options.length] = new
	Option('$250','250');
	  policyAmount.options[policyAmount.options.length] = new
	Option('$300','300');
	  policyAmount.options[policyAmount.options.length] = new
		Option('$400','400');
	}
	if (chosen == "Medical Payment") {
	  policyAmount.options[policyAmount.options.length] = new
	Option('$1000','1000');
	  policyAmount.options[policyAmount.options.length] = new
	Option('$2000','2000');
	  policyAmount.options[policyAmount.options.length] = new
		Option('$3000','3000');
	}
	if (chosen == "Physical Damage") {
		  policyAmount.options[policyAmount.options.length] = new
		Option('$5000','5000');
		  policyAmount.options[policyAmount.options.length] = new
		Option('$10,000','10000');
		  policyAmount.options[policyAmount.options.length] = new
			Option('$15,000','15000');
		}
	
	}
function listboxchange1(p_index) {

	  //Clear Current options in make
	  document.vehicleForm.make.options.length = 0;

	  //Clear Current options in model
	  document.vehicleForm.model.options.length = 0;
	  document.vehicleForm.model.options[0] = new Option("Select Model", "");

	  switch (p_index) {

	  case "2":
	  document.vehicleForm.make.options[0] = new Option("Select Make", "");

	  document.vehicleForm.make.options[1] = new Option("Bajaj", "Bajaj");

	  document.vehicleForm.make.options[2] = new Option("Hero-Honda", "Hero-Honda");
	  break;

	  case "4":
	  document.vehicleForm.make.options[0] = new Option("Select Make", "");

	  document.vehicleForm.make.options[1] = new Option("Maruti", "Maruti");

	  document.vehicleForm.make.options[2] = new Option("BMW", "BMW");

	  break;


	  }
	  return true;
	  }
function listboxchange(p_index) {

	  //Clear Current options in subcategory
	  document.vehicleForm.model.options.length = 0;


	  switch (p_index) {

	  case "Bajaj":
	  document.vehicleForm.model.options[0] = new Option("Select model", "");

	  document.vehicleForm.model.options[1] = new Option("platina", "platina");

	  document.vehicleForm.model.options[2] = new Option("pulser", "pulser");

	  document.vehicleForm.model.options[3] = new Option("pulser dtsi", "pulser-dtsi");

	  break;

	  case "Hero-Honda":
	  document.vehicleForm.model.options[0] = new Option("Select Model", "");

	  document.vehicleForm.model.options[1] = new Option("Splender", "Splender");

	  document.vehicleForm.model.options[2] = new Option("Hunk", "Hunk");

	  break;

	  case "Maruti":
	  document.vehicleForm.model.options[0] = new Option("Select Model", "");

	  document.vehicleForm.model.options[1] = new Option("Alto", "Alto");

	  document.vehicleForm.model.options[2] = new Option("Swift", "Swift");

	  break;

	  case "BMW":
	  document.vehicleForm.model.options[0] = new Option("Select Model", "");

	  document.vehicleForm.model.options[1] = new Option("BMW-100", "BMW-100");

	  document.vehicleForm.model.options[2] = new Option("bmw-200", "bmw-200");

	  break;

	  }
	  return true;
	  }
